package com.unitd.frame.modules.test.dao;

import com.unitd.frame.modules.test.entity.SysUser;
import com.unitd.frame.mybatis.core.dao.IBaseDao;
import com.unitd.frame.mybatis.plugin.cache.annotation.Cache;
import com.unitd.frame.mybatis.plugin.pagination.annotation.Pageable;
import com.unitd.frame.mybatis.plugin.pagination.comm.Page;
import com.unitd.frame.mybatis.plugin.pagination.comm.PageParams;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @desc 信息数据库操作接口类
 * @filename SysUserMapper.java
 * @copyright www.unitd.com
 * @author hudan
 * @version 1.0
 * @date 2018-11-30
 */
@Repository
public interface SysUserMapper extends IBaseDao<SysUser, Long> {

	@Cache
	@Pageable
	List<SysUser> findByStatus(short status);

	@Cache
	SysUser findByMobile(@Param("mobile") String mobile);

	@Cache(expire = 300)
	List<String> findMobileByIds(List<Integer> ids);

	@Cache
	@Pageable
	List<SysUser> queryByExample(SysUser user);

	@Cache
	int countByExample(SysUser user);

	@Cache
	SysUser findByLoginName(@Param("userName") String userName);

	int updateType(@Param("ids") int[] ids, @Param("type") int type);

	void updateTypeBy(SysUser user);

	@Select("SELECT * FROM sys_user where 1=1")
	@ResultMap("BaseResultMap")
	Page<SysUser> pageQuery(@Param("pageParam") PageParams pageParam);
}